<!DOCTYPE>
<html>
    <head>
        <meta charset='utf-8'>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <script src="esl.js"></script>
        <script src="config.js"></script>
    </head>
    <body>
        <style>
            html, body, #main {
                width: 100%;
                height: 100%;
            }
        </style>
        <div id="main"></div>
        <script>
            require([
                'echarts',
                'ecStat'
            ], function (echarts, ecStat) {
                var chart = echarts.init(document.getElementById('main'));
                window.onresize = function () {
                        chart.resize();
                };
                // var height = [70, 65, 63, 72, 81, 83, 66, 75, 80, 75, 79, 76, 76, 69, 75, 74, 85, 86, 71, 64, 78, 80, 74, 72, 77, 81, 82, 80, 80, 80, 87];
                var girth = [8.3,8.6, 8.8, 10.5, 10.7, 10.8, 11.0, 11.0, 11.1, 11.2, 11.3, 11.4, 11.4, 11.7, 12.0, 12.9, 12.9, 13.3, 13.7, 13.8, 14.0, 14.2, 14.5, 16.0, 16.3, 17.3, 17.5, 17.9, 18.0, 18.0, 20.6];
                var testdata = [0.87659, 0.68975, 0.78613];
                var bins = ecStat.histogram(girth);

                var option = {
                    title: {
                        text: 'Girths of Black Cherry Trees',
                        left: 'center',
                        top: 20
                    },
                    color: ['rgb(25, 183, 207)'],
                    grid: {
                        left: '3%',
                        right: '3%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: {
                        // boundaryGap: '5%',
                        scale: true, //这个一定要设，不然barWidth和bins对应不上
                    },
                    yAxis: {
                    },
                    series: [{
                        name: 'height',
                        type: 'bar',
                        barWidth: '99.3%',
                        // barCategoryGap: 0,
                        label: {
                            normal: {
                                show: true,
                                position: 'insideTop'
                            }
                        },
                        data: bins.data
                    }]
                };
                chart.setOption(option);
            });
        </script>
    </body>
</html>